<?php
$hide_right_sidebar = true;
if (current_user_can('legg_til_aktivitet')) { ?>
<form method="post" action="<?php the_permalink() ?>">
    <input name="action" type="submit" value="Ny aktivitet"/>
</form>
<?php } ?>
<table id="ham-innhold-aktivitet-tabell">
    <tbody class="ham-aktivitet-tabell">
<?php
global $wp_locale, $week_begins;
$datoer = ham_aktivitetsdager(is_user_logged_in());
foreach ($datoer as $dato) {
    $aktiviteter = ham_dagens_aktiviteter($dato['fradato'], is_user_logged_in());?>
        <tr class="ham-aktivitet-tabell-rad">
            <td class="ham-aktivitet-dato">
                <h3 class="ham-aktivitet-dato-tittel">
                    <div class="ham-aktivitet-dato-mnd"><?php echo $wp_locale->get_month_abbrev($wp_locale->get_month($dato['mnd'])); ?></div>
                    <div class="ham-aktivitet-dato-dag<?php if ($dato['ukedag'] - $week_begins == 0) echo '-søn' ?>"><?php echo $dato['dag']; ?></div>
                    <div class="ham-aktivitet-dato-udg"><?php echo $wp_locale->get_weekday_abbrev($wp_locale->get_weekday($dato['ukedag'] - $week_begins)); ?></div>
                </h3>
            </td>
            <td class="ham-aktivitet-liste-kolonne">
                <ol class="ham-aktivitet-liste">
<?php foreach ($aktiviteter as $aktivitet) { ?>
                    <li class="ham-aktivitet-liste-rad"> 
                        <form method="post" action="<?php the_permalink() ?>">
                            <a class="ham-aktivitet-liste-tekst">
                                <span class="ham-aktivitet-liste-tekst-tid"><?php echo ham_maketime($aktivitet['time'], $aktivitet['min']) ?></span>
                                <span><?php echo $aktivitet['arr']; ?></span>
                            </a>
                            <input name="action" type="submit" value="Vis aktivitet" style="float:right;"/>
                            <input name="id-value" type="hidden" value="<?php echo $aktivitet['aID'] ?>"/>
                        </form>
                    </li>
<?php } ?>
                </ol>
            </td>
        </tr>
<?php } ?>
    </tbody>
</table>